/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.kth.lwr.jeat.samples.onsitetreatment.producers;

import javax.measure.quantity.VolumetricDensity;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.jscience.physics.amount.Amount;
import se.kth.lwr.jeat.core.*;
import se.kth.lwr.jeat.utils.DefaultAmountConverter;
import se.kth.lwr.jeat.samples.onsitetreatment.SimpleProduction;
import se.kth.lwr.jeat.utils.ProductionSupport;


/**
 *
 * @author davidev
 */
public class ConcreteProducer extends SimpleProduction {
    
    private ConcreteProducer(ProductionSupport support) {
        super(support);
    }
    
    public static ConcreteProducer getInstance() {

        ProductionSupport support = new ProductionSupport("concrete", concreteEmissions, SI.KILOGRAM);
        DefaultAmountConverter handler=(DefaultAmountConverter) support.getAmountConverter();
        AmountFunction function=new AmountFunction(densityConcrete);
        handler.setAcceptFunction(SI.CUBIC_METRE, function);
        return new ConcreteProducer(support);
        
        
        
    }
//Data sources
    /**
     *
     * Emissions during concrete production
     *
     */
    public static final InventoryDataSource concreteEmissions = new InventoryDataSource("ConcreteProducerEmissions",
            "Emissions during concrete production",
            new Inventoriable() {
                
                @Override
                public Inventory getInventory() {
                    Inventory retval = Inventory.emptyInventory();
                    retval.addEnergyUse(EnergyCategory.FOSSIL, Amount.valueOf(0.774, Unit.valueOf("MJ/kg")));
                    retval.addEnergyUse(EnergyCategory.ELECTRICAL, Amount.valueOf(0.0751, Unit.valueOf("MJ/kg")));
                    return retval;
                }
            });
    
    /**
     * Density of concrete
     * <p/>
     * Value: 2.35
     * <p/>
     * Unit: ton/m3
     */
    public static final AmountDataSource densityConcrete = new AmountDataSource<>(
            "densityConcrete",
            "Density of concrete",
            (Amount<VolumetricDensity>) Amount.valueOf(2.35, SI.KILO(SI.KILOGRAM).divide(SI.CUBIC_METRE)));
}
